﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using JabberBotCore;

namespace CommonGame
{
    public class GameBase
    {
        private readonly PManager _pm;
        private readonly JabberBotCore.Core _core = new Core();

        public GameBase()
        {
            _pm = new PManager();
            _pm.LoadPlayers();
            _core.OnMsg += _core_OnMsg;  

        }

        void _core_OnMsg(JabberBotCore.JProtEvArgs args)
        {
            var command = helper.msg.MsgToCommand(args.Msg);

            if (command == null) 
                return;
            command.Owner = args.Owner;
            CommandBase cm = null;
            switch (command.CommandType.ToLower())
            {
                case "register":
                    command.CommandBase = new CommonGame.Commands.Register(args.Owner,command.Msg,args.JProt);
                    break;
            }
            
            _core.QueueCommand(command);
        }

        
    }
}
